const fp = require('lodash/fp');
const { Container, Maybe } = require('./question');


// question-01
let maybe = Maybe.of([5, 6, 1]);
let ex1 = (number) => {
  return  maybe.map(fp.map(fp.add(number)))
}
// console.log(ex1(1))


// question-02
let xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'xi', 'do'])
let ex2 = () => {
  return xs.map(fp.first)
}
// console.log(ex2())


// question-03
let safeProp = fp.curry(function(x, o){
  return Maybe.of(o[x])
})
let user = {id: 2, name: 'Albert'};
let ex3 = (obj) => {
  return safeProp('name')(obj).map(fp.first)
};
// console.log(ex3(user))


// question-04
let ex4 = function(n){
  let maybe = Maybe.of(n)
  return maybe.map(parseInt)
}
// console.log(ex4(null))